const router = require('koa-router')()
const { User } = require('../../models/index')
router.prefix('/users')



// { name, id, tel, adress, role, IDCard, realName, pwd }
router.post('/update', async (ctx, next) => {
    let params = ctx.request.body

    await User.updateOne({ id: params.id }, {
        name: params.name,
        tel: params.tel,
        adress: params.adress,
        role: params.role,
        IDCard: params.IDCard,
        realName: params.realName,
        pwd: params.pwd

    }).then(res => {
        ctx.body = {
            code: 200,
            msg: '修改成功',
            resut: res
        }

    }).catch(err => {
        ctx.body = {
            code: 400,
            msg: '添加时出现异常'
        }
    })
})
module.exports = router